package qnb.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import qnb.dao.StatisticsMapper;
import qnb.service.StatisticsService;
import qnb.service.TeacherService;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author huangxin
 * @date 2019/5/30-15:47
 */
@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    private StatisticsMapper statisticsMapper;



    @Override
    public List<Map<String, Object>> statisticsStudentGrade() {
        List<Map<String, Object>> maps = statisticsMapper.statisticsStudentGrade();
        maps.stream().forEach(map->{
            String id = (String) map.get("name");
            String teacherName = statisticsMapper.findTeacherName(id);
            map.put("name",teacherName);
        });

        return maps;
    }

    @Override
    public List<Map<String, Object>> statisticsStudentIn() {
        List<String> months = Arrays.asList("01", "02", "03", "04", "05","06","07","08","09","10","11","12");
        List<Map<String, Object>> maps = statisticsMapper.statisticsStudentIn();
//        maps.stream().forEach(map -> {
//            Object name = map.get("name");
//            if (name!=null){
//                if (months.contains(name)){
//                    months.remove(name.toString());
//                }
//            }
//        });
//
//        months.stream().forEach(month->{
//            Map map = new HashMap();
//            map.put("name",month);
//            map.put("y",0);
//            maps.add(map);
//        });

        return maps;
    }
}
